﻿@model List<PartyManagement.Models.Food>

@{
    ViewBag.Title = "GetFoodList";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Foods</h2>
@{Html.RenderAction("_FoodCategoryPartial", "Food");}
<div style="float: right; border: 1px solid #000; border-radius: 5px; padding-left: 20px">
    @using (Html.BeginForm("GetFoodList", "Food", FormMethod.Post))
    {
        <table style="width: 600px;">
            <tr>
                <th style="width: 60%;">Food name</th>
                <th style="width: 25%">Quantity Available</th>
                <th>
                    <input type="checkbox" id="selectAll" /></th>
            </tr>
            @foreach (var item in Model)
            {
                <tr>
                    <td style="width: 60%;">@item.foodName</td>
                    <td style="width: 25%">@item.quantity</td>
                    <td style="text-align: center;">
                        <input type="checkbox" value="@item.foodID" class="chkId" name="chkID"/></td>
                </tr>
            }
        </table>
        <input type="submit" value="Insert" />
    }

    <script>
        $("#selectAll").click(function () {
            var checked = $(this).is(':checked');
            $(".chkId").attr("checked", checked);
        });
        $(".chkId").click(function () {
            var valid = true;
            $(".chkId").each(function () {
                var checked = $(this).is(':checked');
                if (!checked) {
                    valid = false;
                }
            });
            $("#selectAll").attr("checked", valid);
        });
    </script>
</div>
<div style="clear:both;"></div>
<p>@Html.ActionLink("Back to your menu", "GetMenuForEvent", "Menu", new { id = @Session["menu_id"] }, null)</p>
